home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Hardware / Mac OS USB DDK / Mac OS USB DDK 1.4.1 / Examples / USBSampleStorageDriver / UnitTableDriver / UnitTableDriveQSupport.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-25  |  6.0 KB  |  134 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        UnitTableDriveQSupport.h
  3.  
  4.     Contains:    All drive queue and Volume queue specific functions
  5.  
  6.     Version:    1.0
  7.  
  8.     Copyright:    © 1998-1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12. #pragma once
  13.  
  14. #include <MacTypes.h>
  15. #include <Disks.h>
  16. #include <Files.h>
  17.  
  18. #include "UnitTableDeviceAccess.h"    // Needed for ControlStatusCompletionProcPtr structure
  19. #include "UnitTableDriverIcons.h"    // Needed for DiskIcon structure
  20.  
  21. // The blocksize that all file system requests are based on
  22. enum
  23. {
  24.     kFileSystemRequestBlockSize = 0x00000200L
  25. };
  26.  
  27. // The control/status call definitions for Utility Mode
  28. enum
  29. {
  30.     kdgDriverUtilitySupport = 'util',    // For right now, this DriverGestalt will return true if the following
  31.                                         // calls are supported.  The final version of this call will actually
  32.                                         // set attribute flags to indicate which uility features it supports
  33.  
  34.     kcsSetDriverMode = 600,                // Control call for switching between Normal/Utility mode
  35.     kcsGetDriverMode = 600,                // Status call for querying current driver mode
  36.     
  37.     // Definitions for the modes  These are passed in csParam[0].
  38.     kDriverModeNormal = 1,
  39.     kDriverModeUtility = 2,
  40.     
  41.     kcsManageReadOnlyMediaQueue = 601,
  42.     // Definitions  Read Only Media queue management.  These are passed in in csParam[0]
  43.     kReadOnlyMediaQueueInstall = 1,        // If installed without errors, the DriveNum is returned in csParam[1]
  44.     kReadOnlyMediaQueueRemove = 2
  45. };
  46.  
  47. // Media icon/string structure format
  48. struct MediaIconStruct    
  49. {
  50.     SInt8    mediaIcon[256];                // ICN# data is 256 bytes 
  51.     Str255    mediaWhereString;            // returned in C string format
  52. };
  53. typedef struct MediaIconStruct MediaIconStruct;
  54.  
  55. // This structure defines each physical drive…
  56. struct DriveQRec
  57. {
  58.     // Drive Queue information
  59.     DrvSts2            driveStatus;            // drive status info & queue element
  60.     UInt16            driveNum;                // Position in the Drive Queue
  61.  
  62.     // Physical drive characteristics retreived from the DAM
  63.     UInt32            capacity;                // Drive capacity in native device blocks
  64.     UInt32            blockSize;                // Drive's native block size
  65.     OSType             deviceType;                // The type of device represented.
  66.     Boolean            isWriteProtected;        // The DAM indicated that this device is write protected
  67.  
  68.     // Partition characteristics from the media
  69.     UInt32            partMapEntryNum;        // Block number of the PMap entry for this partition.  Zero means not in a PMap.
  70.                                             // The next three fields are only vaild if there is a PMap entry for this partition.
  71.     Boolean            mountPartition;            // true = Mount Partition bit was set in the partition status field of the PMap
  72. /*    Boolean            startupPartition;        // true = Startup bit was set in the partition status field of the PMap*/
  73.     Boolean            writeProtectedPart;        // true = Write protect bit was set in the partition status field of the PMap
  74.  
  75.     // DriveQRec status fields derived by driver
  76.     Boolean            isValidRecord;            // Indicates if this record is being used
  77.     Boolean            isPermanentQElement;    // Indicates if this should be removed from driveQ on eject
  78.     Boolean            isFloppy;                // This DriveQRec is for floppy media - usage should be replace with the deviceType field
  79.     Boolean            diskInsertPosted;        // true = a Disk Insert event has successfully been posted for this partition.
  80.     Boolean            inDriveQ;                // true = this partition is in the drive Q
  81.     UInt32            partitionNo;            // the partition number for the volume
  82.     UInt32            partoffset;                // phys. offset of data partition in system size blocks
  83.     UInt32            curoffset;                // 0 = physical mapping, else 'partoffset'
  84.     UInt32            partblks;                // number of blocks in the partition in system size blocks
  85.     Ptr                nextVol;                // Link to next volume in the list
  86.     Ptr                mediaIconPtr;            // Pointer to the media icon for this volume
  87. };
  88.  
  89. typedef struct DriveQRec DriveQRec, *DriveQRecPtr;
  90.  
  91. // Install Drive.  The routine that will scan media and install drive queue elements as needed
  92. // Completion routine type for InstallDrive routine
  93. typedef CALLBACK_API_C( void , DriveInstallCompletionProcPtr )( Boolean wasSuccessful );
  94. extern void         InstallDrive( DriveInstallCompletionProcPtr completionProc );
  95.  
  96. // Prototypes for the routines used by Initialize and Terminate
  97. extern OSStatus     InstallDriveQueueElement( DriverRefNum theDrvrRefNum );
  98. extern OSStatus     RemoveDriveQueueElement( void );
  99.  
  100. // If these routines return any OSStatus except Request Pending, then the callback routine will not be called
  101. extern OSStatus     DriveQueueControlCallSupport( UInt32 userData, CntrlParamPtr cntrlPBPtr, ControlStatusCompletionProcPtr callBack );
  102. extern OSStatus     DriveQueueStatusCallSupport( UInt32 userData, CntrlParamPtr cntrlPBPtr, ControlStatusCompletionProcPtr callBack );
  103.  
  104. // Prototypes for DriveQueue query routines
  105. extern Boolean         IsDriveNumberValid( UInt16 driveNum );
  106. extern Boolean         IsDriveNumWriteProtected( UInt16 driveNum );
  107. extern Boolean         AreThereMountedDrives( void );
  108. extern UInt32         GetNumberOfVolumes( void );
  109. extern void         GetMediaIconForDriveNum( UInt16 driveNum, DiskIcon    *iconPtr );
  110. extern void         GetDriveStatusForDriveNum( UInt16 driveNum, DrvSts *statusPtr );
  111. extern OSType         GetMediaTypeForDriveNum( UInt16 driveNum );
  112.  
  113. // Prototypes for routines to find a DriveQRec
  114. extern DriveQRecPtr FindDriveQRecForDriveNum( UInt16 driveNum );
  115. extern DriveQRecPtr FindDriveQRecForPartitionNum( UInt32 partNum );
  116. extern DriveQRecPtr GetFirstDriveQRec( void );
  117. extern DriveQRecPtr GetNextDriveQRec( DriveQRecPtr theDriveQRec );
  118.  
  119. // Routines for managing the state of a DriveQRec
  120. extern void         EjectDriveNum( UInt16 driveNum );
  121. extern SInt16        NextQDrive( void );
  122. extern void            UpdateQ(SInt16 qDrive, SInt32 newSize);
  123. extern SInt32        NextPartitionID( void );
  124.  
  125. extern DriveQRecPtr    CreateNewDriveQRecForPartition( UInt32 partitionID, UInt32 partitionSize, UInt32 partitionOffset );
  126.  
  127. // These should only be used by the media specific support modules (CD or Floppy) to manage its DriveQRec
  128. extern DriveQRecPtr    GetNewDriveQRec( void );
  129. extern void         FreeDriveQRec( DriveQRecPtr theDriveRecPtr );
  130. extern void         NativeAddDrive(DriverRefNum drvrRefNum, UInt16 driveNumber, DrvQElPtr drvQEl);
  131. extern void         RemoveDrive(DriveQRecPtr theDrivePtr);
  132. extern Boolean        IsDriveQueueNumberFree( UInt16 driveNum );
  133.  
  134.